package com.itheima.service;

import com.itheima.mapper.CustomerMapper;
import com.itheima.pojo.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service  //服务层Bean

public class CustomerService {
    @Autowired
    private CustomerMapper customerMapper;
    /**
     * 功能：登录
     *
     * @param username 账号
     * @param pass     密码
     * @return
     */
    public Customer login(String username, String pass) {
        return customerMapper.findByUandP(username, pass);
    }

    /**
     * 功能：账号是否存在
     *
     * @param username 账号
     * @return
     */
    public int usernameIsExist(String username) {
        return customerMapper.usernameIsExist(username);
    }
    /**
     * 功能：添加
     *
     * @param customer
     * @return
     */
    public int register(Customer customer) {
        return customerMapper.insert(customer);
    }

    /**
     * 功能：电话是否存在
     *
     * @param tel 电话
     * @return
     */
    public int telIsExist(String tel) {
        return customerMapper.telIsExist(tel);
    }

    /**
     * 功能：修改
     *
     * @param customer
     * @return
     */
    public int update(Customer customer) {
        return customerMapper.update(customer);
    }

    public Customer findById(int id) {
        return customerMapper.findById(id);
    }

    public int pswIsCorrect(String pass) {
        return customerMapper.pswIsCorrect(pass);
    }

    public int passIsExist(String pass) {
        return customerMapper.passIsExist(pass);
    }
}